package com.xq.action;

import com.xq.pojo.People;
import com.xq.service.PeopleService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * @author xq
 * @version 1.0
 * @date 2021/4/6 17:39
 * @description 人们控制器
 */
@Setter
@Controller  // 注入到Ioc容器中，标识为控制器对象
public class PeopleAction {

    @Autowired
    private PeopleService peopleService;

    /**
     * 添加人们
     * @param p 人们对象
     */
    public Integer addPeople(People p) {
        return this.peopleService.addPeople(p);
    }

    /**
     * 修改人们
     * @param p 人们对象
     */
    public Integer updatePeople(People p) {
        return this.peopleService.updatePeople(p);
    }

    /**
     * 根据Id删除人们
     * @param id 人们ID
     */
    public Integer deletePeopleById(Integer id) {
        return this.peopleService.deletePeopleById(id);
    }

    /**
     * 获取人们数据
     */
    public List<People> getAllPeople() {
        return this.peopleService.getAllPeople();
    }

    /**
     * 根据id查询人们信息
     * @param id 人们ID
     * @return 返回人们信息
     */
    public People getPeopleById(Integer id) {
        return this.peopleService.getPeopleById(id);
    }

}
